function k = calculateConsecutiveMatrixApplication(n,p,theta)
    % according to ESTIMATING EXTREMAL EIGENVALUES AND CONDITION NUMBERS OF MATRICES
    % to ensure 1-10^-p probability for the esstimated condition number of a matrix will be
    % bounded between the actual condition number c and theta*c we need to make k 
    % consecutive matrix application where k = (2p+log(n)-.19)/log(theta)
    % with all logarithms to base 10
    
    % default parameters are very strict
    % 99.999% probability for the esstimation to be bounded between actual condition number c and 1.001c
    if nargin < 1
      error('calculateConsecutiveMatrixApplication matrix size');
    end
    if nargin < 2
      p=6;
    end
    if nargin < 3
      theta=1.001;
    end
    k=ceil((2*p+(log(n)/log(10))-.19)/(log(theta)/log(10)));
end